import React, {Component} from 'react'
import {
    StyleSheet, Text,
    View, FlatList
} from 'react-native'
import {observable, runInAction, autorun} from 'mobx';
import {observer} from 'mobx-react/native';
import jsondata from '../json/nearbylistpage.json'
import Neardygridviewpage from '../component/neardygridviewpage'
import ShopListpage from "./ShopListpage";

@observer
export default class NearbyItem extends Component {
    @observable
    dataSource = [];
    @observable
    isRefresh = true;

    constructor(props) {
        super(props);
        this.state = {}
    }

    componentDidMount() {
        this.loadDataSource(1);
    }


    render() {
        const {navigate} = this.props;
        let {tabLabel, type} = this.props;
        return (
            <View>
                <Neardygridviewpage menuInfos={this.loadMenuInfos(type)}/>
                <FlatList
                    data={this.dataSource}
                    keyExtractor={item => item.id}
                    renderItem={({item}) => this.renderItem(item)}
                />
            </View>
        );
    }

    renderItem = (item) => {
        const {navigate} = this.props;
        return (
            <ShopListpage navigate={navigate} itemData={item} itemPress={() => this.itemPress(item)}/>
        )
    };

    loadMenuInfos(type) {
        return jsondata.type[type].content;
    };

    loadDataSource(type) {
        this.dataSource = jsondata.data
    }
}
module.exports = NearbyItem